package com.le.tester.javaThink.fifth.chapter12_Collections;

import java.util.ArrayList;

/**
 * createTime：2021/8/24 14:13
 * description：类的转换异常
 */

class Apple {
    private static long counter;
    private final long id = counter++;

    public long id() {
        return id;
    }
}

class Orange {
}

public class ApplesAndOrangesWithoutGenerics {
    public static void main(String[] args) {
        ArrayList apples = new ArrayList();
        for (int i = 0; i < 3; i++)
            apples.add(new Apple());
        apples.add(new Orange());
        for (Object apple : apples) {
            ((Apple) apple).id();
        }
    }
}
